package org.cms.dao;

import org.cms.entities.CheckIn;
import org.cms.entities.JiraIssue;

import javax.ejb.Stateless;
import javax.persistence.NoResultException;
import java.util.List;
import java.util.logging.Logger;

/**
 * Created by elnoa on 19/10/14.
 */
@Stateless(name = "TaskDao")
public class TaskDao extends AbstractDao<JiraIssue,String> {

    Logger log = Logger.getLogger(TaskDao.class.getName());

    public List<CheckIn> getAllCheckIn() {

        List<CheckIn> checkIns = em.createNamedQuery("getAllCheckIn", CheckIn.class).getResultList();

        log.info("Ich habe " + checkIns.get(0).getShout());
        log.info("hala wala");

        return null;
    }

    public boolean checkInExist(String id) {
        try {
            CheckIn checkIns = em.createNamedQuery("getCheckInByID", CheckIn.class).setParameter("id", id).getSingleResult();
        } catch (NoResultException ex) {

            return false;
        }

        return true;

    }
}
